%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/one-to-one-backward"
    Bucket0("Bucket 0 (root)<br /><br />1: 71, 79<br />ᐳ: 9, 10, 38, 42, 11<br />2: 75, 83<br />3: PgSelect[8]<br />ᐳ: Access[19], Access[76], Access[84]<br />4: Connection[12]<br />5: ConnectionItems[14]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 19, 14, 76, 84, 38, 42<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 19, 76, 84, 38, 42<br /><br />ROOT __Item{3}ᐸ14ᐳ[17]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 17, 18, 76, 84, 38, 42, 20<br /><br />ROOT Edge{3}[18]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 21, 76, 84, 38, 42<br /><br />ROOT PgSelectSingle{4}ᐸpersonᐳ[21]<br />1: <br />ᐳ: 22, 23, 25, 77, 85, 78, 86<br />2: PgSelectRows[31], PgSelectRows[36]<br />ᐳ: 30, 32, 35, 37"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 32, 38, 78<br /><br />ROOT PgSelectSingle{5}ᐸleft_armᐳ[32]<br />1: <br />ᐳ: 39, 46, 62, 72, 40, 41, 73, 74<br />2: PgSelectRows[59]<br />ᐳ: First[58], PgSelectSingle[60]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 37, 42, 86<br /><br />ROOT PgSelectSingle{5}ᐸperson_secretᐳ[37]<br />1: <br />ᐳ: 43, 61, 80, 44, 45, 81, 82<br />2: PgSelectRows[52]<br />ᐳ: First[51], PgSelectSingle[53]"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 53<br /><br />ROOT PgSelectSingle{7}ᐸpersonᐳ[53]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 60<br /><br />ROOT PgSelectSingle{6}ᐸpersonᐳ[60]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6 & Bucket7
    Bucket6 --> Bucket9
    Bucket7 --> Bucket8

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸpersonᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply75["PgSelectInlineApply[75∈0] ➊"]:::plan
    PgSelectInlineApply83["PgSelectInlineApply[83∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply75 & PgSelectInlineApply83 --> PgSelect8
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    ConnectionItems14[["ConnectionItems[14∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems14
    Access19{{"Access[19∈0] ➊<br />ᐸ8.cursorDetailsᐳ"}}:::plan
    PgSelect8 --> Access19
    PgSelectInlineApply71["PgSelectInlineApply[71∈0] ➊"]:::plan
    PgSelectInlineApply71 --> PgSelectInlineApply75
    Access76{{"Access[76∈0] ➊<br />ᐸ8.m.joinDetailsFor26ᐳ"}}:::plan
    PgSelect8 --> Access76
    PgSelectInlineApply79["PgSelectInlineApply[79∈0] ➊"]:::plan
    PgSelectInlineApply79 --> PgSelectInlineApply83
    Access84{{"Access[84∈0] ➊<br />ᐸ8.m.joinDetailsFor33ᐳ"}}:::plan
    PgSelect8 --> Access84
    Edge18{{"Edge[18∈3]"}}:::plan
    __Item17[/"__Item[17∈3]<br />ᐸ14ᐳ"\]:::itemplan
    PgCursor20{{"PgCursor[20∈3]"}}:::plan
    __Item17 & PgCursor20 --> Edge18
    __Item17 & Access19 --> PgCursor20
    ConnectionItems14 ==> __Item17
    PgSelectSingle21{{"PgSelectSingle[21∈4]<br />ᐸpersonᐳ"}}:::plan
    __Item17 --> PgSelectSingle21
    List77{{"List[77∈5]<br />ᐸ76,21ᐳ"}}:::plan
    Access76 & PgSelectSingle21 --> List77
    List85{{"List[85∈5]<br />ᐸ84,21ᐳ"}}:::plan
    Access84 & PgSelectSingle21 --> List85
    PgClassExpression22{{"PgClassExpression[22∈5]<br />ᐸ__person__.”id”ᐳ"}}:::plan
    PgSelectSingle21 --> PgClassExpression22
    PgClassExpression23{{"PgClassExpression[23∈5]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgClassExpression22 o--o PgClassExpression23
    PgClassExpression25{{"PgClassExpression[25∈5]<br />ᐸ”c”.”perso..._person__)ᐳ"}}:::plan
    PgClassExpression23 o--o PgClassExpression25
    First30{{"First[30∈5]"}}:::plan
    PgSelectRows31[["PgSelectRows[31∈5]"]]:::plan
    PgSelectRows31 --> First30
    Lambda78{{"Lambda[78∈5]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda78 --> PgSelectRows31
    PgSelectSingle32{{"PgSelectSingle[32∈5]<br />ᐸleft_armᐳ"}}:::plan
    First30 --> PgSelectSingle32
    First35{{"First[35∈5]"}}:::plan
    PgSelectRows36[["PgSelectRows[36∈5]"]]:::plan
    PgSelectRows36 --> First35
    Lambda86{{"Lambda[86∈5]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda86 --> PgSelectRows36
    PgSelectSingle37{{"PgSelectSingle[37∈5]<br />ᐸperson_secretᐳ"}}:::plan
    First35 --> PgSelectSingle37
    List77 --> Lambda78
    List85 --> Lambda86
    List40{{"List[40∈6]<br />ᐸ38,39ᐳ<br />More deps:<br />- Constantᐸ'left_arms'ᐳ[38]"}}:::plan
    PgClassExpression39{{"PgClassExpression[39∈6]<br />ᐸ__left_arm__.”id”ᐳ"}}:::plan
    PgClassExpression39 --> List40
    List73{{"List[73∈6]<br />ᐸ72,32ᐳ"}}:::plan
    Access72{{"Access[72∈6]<br />ᐸ78.m.joinDetailsFor54ᐳ"}}:::plan
    Access72 & PgSelectSingle32 --> List73
    PgSelectSingle32 --> PgClassExpression39
    Lambda41{{"Lambda[41∈6]<br />ᐸbase64JSONEncodeᐳ"}}:::plan
    List40 --> Lambda41
    PgClassExpression46{{"PgClassExpression[46∈6]<br />ᐸ__left_arm...person_id”ᐳ"}}:::plan
    PgSelectSingle32 --> PgClassExpression46
    First58{{"First[58∈6]"}}:::plan
    PgSelectRows59[["PgSelectRows[59∈6]"]]:::plan
    PgSelectRows59 --> First58
    Lambda74{{"Lambda[74∈6]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda74 --> PgSelectRows59
    PgSelectSingle60{{"PgSelectSingle[60∈6]<br />ᐸpersonᐳ"}}:::plan
    First58 --> PgSelectSingle60
    PgClassExpression62{{"PgClassExpression[62∈6]<br />ᐸ__left_arm...in_metres”ᐳ"}}:::plan
    PgClassExpression46 o--o PgClassExpression62
    Lambda78 --> Access72
    List73 --> Lambda74
    List44{{"List[44∈7]<br />ᐸ42,43ᐳ<br />More deps:<br />- Constantᐸ'person_secrets'ᐳ[42]"}}:::plan
    PgClassExpression43{{"PgClassExpression[43∈7]<br />ᐸ__person_s...person_id”ᐳ"}}:::plan
    PgClassExpression43 --> List44
    List81{{"List[81∈7]<br />ᐸ80,37ᐳ"}}:::plan
    Access80{{"Access[80∈7]<br />ᐸ86.m.joinDetailsFor47ᐳ"}}:::plan
    Access80 & PgSelectSingle37 --> List81
    PgSelectSingle37 --> PgClassExpression43
    Lambda45{{"Lambda[45∈7]<br />ᐸbase64JSONEncodeᐳ"}}:::plan
    List44 --> Lambda45
    First51{{"First[51∈7]"}}:::plan
    PgSelectRows52[["PgSelectRows[52∈7]"]]:::plan
    PgSelectRows52 --> First51
    Lambda82{{"Lambda[82∈7]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda82 --> PgSelectRows52
    PgSelectSingle53{{"PgSelectSingle[53∈7]<br />ᐸpersonᐳ"}}:::plan
    First51 --> PgSelectSingle53
    PgClassExpression61{{"PgClassExpression[61∈7]<br />ᐸ__person_s..._.”sekrit”ᐳ"}}:::plan
    PgSelectSingle37 --> PgClassExpression61
    Lambda86 --> Access80
    List81 --> Lambda82
    PgClassExpression63{{"PgClassExpression[63∈8]<br />ᐸ__person__.”id”ᐳ"}}:::plan
    PgSelectSingle53 --> PgClassExpression63
    PgClassExpression65{{"PgClassExpression[65∈8]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgClassExpression63 o--o PgClassExpression65
    PgClassExpression68{{"PgClassExpression[68∈8]<br />ᐸ”c”.”perso..._person__)ᐳ"}}:::plan
    PgClassExpression65 o--o PgClassExpression68
    PgClassExpression64{{"PgClassExpression[64∈9]<br />ᐸ__person__.”id”ᐳ"}}:::plan
    PgSelectSingle60 --> PgClassExpression64
    PgClassExpression66{{"PgClassExpression[66∈9]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgClassExpression64 o--o PgClassExpression66
    PgClassExpression70{{"PgClassExpression[70∈9]<br />ᐸ”c”.”perso..._person__)ᐳ"}}:::plan
    PgClassExpression66 o--o PgClassExpression70

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,ConnectionItems14,Access19,PgSelectInlineApply71,PgSelectInlineApply75,Access76,PgSelectInlineApply79,PgSelectInlineApply83,Access84 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item17,Edge18,PgCursor20 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle21 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression22,PgClassExpression23,PgClassExpression25,First30,PgSelectRows31,PgSelectSingle32,First35,PgSelectRows36,PgSelectSingle37,List77,Lambda78,List85,Lambda86 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression39,List40,Lambda41,PgClassExpression46,First58,PgSelectRows59,PgSelectSingle60,PgClassExpression62,Access72,List73,Lambda74 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression43,List44,Lambda45,First51,PgSelectRows52,PgSelectSingle53,PgClassExpression61,Access80,List81,Lambda82 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,PgClassExpression63,PgClassExpression65,PgClassExpression68 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression64,PgClassExpression66,PgClassExpression70 bucket9

